<?php

/**
 * Highlight
 * Plugin that provides code highlighting with JS library SHJS
 * Home of SHJS: http://shjs.sourceforge.net/
 * @package
 * @author kubicek
 * @copyright Copyright (c) 2010
 * @version $Id$
 * @access public
 */
class Highlight extends Plugin
{
	public $plugin_name = "Highlight";
	public $plugin_short_desc = "Highlighting plugin";
	public $plugin_long_desc = "Syntax highlighting with JS library SHJS";
	public $version = "1.0";

	/**
	 * Constructor
	 */
	function __construct()
	{
		global $theme;

		$theme->include_jquery();
		$theme->include_js($this->get_plugin_path().'sh_main.min.js');
		$theme->include_css($this->get_plugin_path().'sh_style.min.css');
		$theme->js("sh_highlightDocument('".$this->get_plugin_path()."lang/', '.min.js');");
	}

	/**
	 * Highlight::text()
	 * Echo highlighted text in given language
	 * @param mixed $text
	 * @param mixed $language
	 * @return
	 */
	public function text($text,$language = 'php')
	{
		return '<pre class="sh_'.$language.'">'.$text.'</pre>';
	}

	public function admin_settings()
	{

		echo '<p>Official documentation: <a href="http://shjs.sourceforge.net/">http://shjs.sourceforge.net/</a></p>
<p>Usage in Yaps!: </p>';

		$text = '$highlight = $core->load_plugin(\'highlight\');
$highlight->text(\'print_r($array);\',\'php\');';

		echo '<div class="code">',nl2br($text),'</div><p>And highlighted code:</p>';
		echo $this->text($text);
	}
}


?>